home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / system / mail / transpor / ifmail23.z / ifmail23 / ifmail / misc / sumlog < prev    next >
Encoding:
Text File  |  1993-12-17  |  657 b   |  31 lines

  1. #!/usr/bin/perl
  2.  
  3. #Execute: "sumlog iflog"
  4. #Outputs: address starttime enddtime result (seconds)
  5.  
  6. while ( <> ) {
  7.     if (/.* (.*) ([0-9]*) calling/) {
  8.         #print "start time $1 id $2\n";
  9.         $str{$2} = $1;
  10.     }
  11.     if (/.* (.*) ([0-9]*) call to ([^ ]*) ([^ ]*)/) {
  12.         #print "end   time $1 id $2\n";
  13.         if ($st = $str{$2}) {
  14.             delete $str{$2};
  15.             $tot=&diff($1,$st);
  16.             print "$3 $st $1 $4 ($tot)\n";
  17.         }
  18.     }
  19. }
  20.  
  21. sub diff {
  22.     local($res);
  23.     local($h1,$m1,$s1,$h2,$m2,$s2);
  24.     ($h1,$m1,$s1) = split(/:/,@_[0]);
  25.     ($h2,$m2,$s2) = split(/:/,@_[1]);
  26.     $res = $h1*3600+$m1*60+$s1-$h2*3600-$m2*60-$s2;
  27.     if ($res < 0) { $res = 86400 + $res; }
  28.     #print "@_[0] - @_[1] = $res\n";
  29.     $res;
  30. }
  31.